import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

const store = new Vuex.Store({
    state: {
        userName: "张三",
        userClass: "2020级计算机科学与技术本科2班"
    },
    mutations: {
        setUserName(state, name) {
            state.userName = name;
        }
    },
    actions: {
        updateUserName({ commit }, name) {
            commit("setUserName", name);
        }
    },
    getters: {
        userName: state => state.userName,
        userClass: state => state.userClass
    }
});

export default store;